19. Exercise: Adding Actions to Notifications

Adding Actions to Notifications

Adding Actions to Notifications

In this exercise you'll add the ability to record drinking a cup of water straight from the notification or to clear away the notification entirely.

Exercise Code

Exercise: T10.03-Exercise-NotificationActions

Exercise: Adding Actions to Notifcations

Now it's your turn!

SOLUTION:
  • Add the `ACTION_DISMISS_NOTIFICATION` constant in `ReminderUtils`
  • Add the `clearAllNotifications` method to `NotificationUtils`
  • Update `ReminderTasks` to add clearAllNotifications to `executeTask` and `incrementWaterCount`
  • Add the two Action creation methods to `NotificationUtils`
  • Update the `NotificationBuilder` in `remindUser` to add the two new Actions.